<?php echo javascript_include_tag('general/multiple_selects') ?>
<?php $table_align  = isset($table_align)  ? $table_align  : 'center' ?>
<?php $print_arrows = isset($print_arrows) ? $print_arrows : true ?>

<div id="multiple_selects">
  <?php $attributes_chosen = $form ? array('name' => $form.'[hdn_chosen]', 'id' => 'hdn_chosen') : array() ?>

  <?php echo input_hidden_tag('hdn_available', implode('|', array_keys($options['available']))) ?>
  <?php echo input_hidden_tag('hdn_chosen'   , implode('|', array_keys($options['chosen'])), $attributes_chosen) ?>
  
  <?php list($size['a_width'], $size['a_height']) = split('x', $size['available'], 2); ?>
  <?php list($size['c_width'], $size['c_height']) = split('x', $size['chosen']   , 2); ?>
  
  <table align="<?php echo $table_align ?>" cellpadding="0" cellspacing="0" border="0" class="multiple_selects">
    <tr>
      <td colspan="2" class="multiple_selects_title">
        <?php echo $title['available'] ?>
      </td>
      <td colspan="2" class="multiple_selects_title">
        <?php echo $title['chosen'] ?>
      </td>
    </tr>
    <tr>
      <td>
        <?php echo select_tag_multiple('available', $options['available'], '', array('style' => sprintf('width: %spx; height: %spx;', $size['a_width'], $size['a_height']))) ?>
      </td>
      <td class="multiple_selects_buttons">
        <?php if ($print_arrows): ?>
          <?php echo link_to_function(image_tag('arrow_right.gif'), 'onClickMoveToSelectedButton("available", "chosen")') ?>
          <br/>
          <?php echo link_to_function(image_tag('arrow_left.gif') , 'onClickMoveToSelectedButton("chosen", "available")') ?>
        <?php else: ?>
          <br />
        <?php endif; ?>
      </td>
      <td>
        <?php echo select_tag_multiple('chosen', $options['chosen'], '', array('style' => sprintf('width: %spx; height: %spx;', $size['c_width'], $size['c_height']))) ?>
      </td>
      <?php if ($order): ?>
        <td class="multiple_selects_buttons">
          <?php echo link_to_function(image_tag('arrow_up_list.gif'), 'moveItemUpTop("chosen")') ?>
          <br/>
          <?php echo link_to_function(image_tag('arrow_up.gif'), 'moveItemUp("chosen")') ?>
          <br/>
          <?php echo link_to_function(image_tag('arrow_down.gif'), 'moveItemDown("chosen")') ?>
          <br/>
          <?php echo link_to_function(image_tag('arrow_down_list.gif'), 'moveItemDownBottom("chosen")') ?>
        </td>
      <?php endif; ?>
      <?php if (isset($slot_extra)): ?>
        <?php include_slot($slot_extra) ?>
      <?php endif; ?>
    </tr>
  </table>
</div>
